Class 2 Lab - Latitude & Longitude

IMG

source: Djexplo (Own work) [CC0], via Wikimedia Commons


Lab I:

In this first lab, we will explore decimal precision in latitude and longitude (“lat long”) utilizing as our start ‘point’ high precision lat long. We will degrade that precision 5 times over and then map our results to see the critical role that decimal percision plays in coordinates and resulting points features in mapping.

  • Step 1: Download Data - Part I - Statue of Liberty. Once downloaded, unzip the folder and inside there will be located a .csv file for the Statue of Liberty with a precise lat long coordinate pair that represents the precise location of the statue. As discussed in the lecture, lat long pairings are a very common points feature format used in mapping, often displayed in a coordinate space atop a base map.

  • Step 2: Use a text editor to open the Statue of Liberty .csv file - on a PC utilizing a default editor such as Notepad or Notepad ++; on a Mac OS X, textedit. Once opened, copy/paste the row 5 times, resulting in a total 6 instances of the same row.

Note: now is a good time to explore a robust text editor to employ during this course. Here are some good options.

  • Step 3: Starting with the bottom 6th row, remove the last digit from lat and long decimal numbers respectively. Continue up the .csv removing 1 more digit from lat and long until there are no digits after the decimal point in the second row under the original Statue of Liberty lat long. Save the results as .txt and then simply convert the file extension from .txt to .csv.

  • Step 4: Navigate to geojson.io. At the left, toggle open>file and point to the .csv that has been edited for Statue of Liberty. Import this file. Once complete, we can see the effect of decimal point precision in lat long pairings. This lab illustrates the importance of understanding the following aspects of lat long data in tabular format:

    • The provenance of your data - where did it come from & how was it derived. Often high precision lat long will be derived from GPS units, while other sources of lat long may be less accurate.

    • The precision of the lat long pairings - is the data sufficiently precise to be of value for the scale of your mapping. For large-scale mapping, high precision is usually critical. For small-scale mapping, high precision lat long may not be required.

Lab I Video Guide:

Latitude + Longitude Precision


Lab II:

  • In the preceding lab, latitude and longitude were expressed in tabular columns as decimal numbers. In this way, ‘spatially aware’ utilities are able to translate the numbers onto the WGS84 coordinate system.

    • What happens when latitude and longitude are not available as decimal numbers?
  • One approach is to capture the ‘address’ of a location. Addresses have various levels of precision from highly precise ‘rooftop’ precision (123 Ash Drive, Anytown, Anystate, USA) to much less precise ‘city or town’ (Anytown, Anystate, USA). In the following lab, location is expressed in two columns - a city and its corresponding state. Using a Geocode process, these known ‘address’ locations will be transformed into coordinate locations upon the WGS84 coordinate system. Once done, both X and Y coordinates can be recorded to the dataset attribute table within QGIS.

  • In this Lab II process, we will also learn how to employ the following from within QGIS:

  • Step 1: Download 75 City & States Dataset. Once downloaded, unzip the folder and inside there will be located a .csv file for 75 US cities with their respective states:

  • After loading the 75 US cities dataset into QGIS utilizing Delimited Text as data source, save .qgis as c2_l3.qgis:

  • Step 2: Install the mmqgis plugin, which will be utilized for both geocoding and exporting .shp attribute data as .csv
    • Main Menu > Plugins > Manage and Install Plugins:

  • Step 3: initiate the geocode process via the mmqgis plugin> Geocode CSV with Google/OpenStreetMap

  • Add fields, using the following image as a guide. Be sure to choose Web Service > OpenStreetMap/Nominatim. Make sure to set the input and output directory locations within lab folder. Further, make sure to choose the correct columns for City and State. Since no other fields are available, those can be set to the default (none). Finally, click Apply to run the geocode:

  • Run the geocode, results should look similar to the following (right-click > zoom to layer to see the features in Map Canvas:

Note: expect the geocode to take up to 10 minutes or so, especially if you are on a slow internet connection.

  • Step 4: While the geocode produces .shp geometry that is accurate to the OpenStreetMap geocoding service, it doesn’t produce an x,y coordinate pair per se in the attribute table. Often this locational component is valuable for future mapping purposes. To do this final task, open Field Calculator which is just right of Open Attribute Table from the main toolbar:

  • Proceed to enact Field calculator
  • For Output field name type x_coord first; on the second pass, type y_coord
  • The Output field type will be decimal
  • Keep default Output field length
  • Choose Geometry at right drop-down section, and find $x and $y
  • In the Expression Editor choose $x for x_coord and $y for the y_coord on the second pass.
  • For Precision, make sure to choose just 1 because in this particular mapping instance we started with just city names which lacks a precision greater than ‘large city or district’. Make sure to review the chart from the Wikipedia page for Decimal Degrees, also shown below:

precision

  • Return to map. Turn off Toggle Editing via a right-click > dropdown > Toogle Editing:

  • Review the new x_coord and y_coord fields in the attribute table:

  • Step 5: to export the resulting tabular data with the new x,y coordinates, utilize mmqis again as follows:

Part III Video Guide:

QGIS Geocode

Note: video guide utilizes Google Maps Geocoding API within QGIS 2.x, not the more recent QIS 3.x


Lab III:

  • In this #3 lab, Precision, Scale and Output lengths of numbers in QGIS will be demonstrated. By creating a number Column - also referred to as a Field in QGIS, number types and their format can be set prior to popuation of the column/field with actual data. To follow, create a field in QGIS with the Field Calculator tool in QGIS. This can be accessed several ways within the QGIS Map Canvas interface; and its always available with the attribute table open in the vector model. Test out Precision, Scale, Output Length in several QGIS fields that you create.

  • Precision

Precision, Scale & Output Length

Precision :)

Number Precision and Scale

QGIS Field Calculator

Length and Precision in QGIS


Further References:

.csv overview:

Many alternative, accessible geocoding utilities exist online in addition to Desktop GIS geocoding and API geocoding. To follow are four utilites that are easy to use for smaller datasets:

``